// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/efficiency/api/EnergyOverviewApi'

import InfoClass from '@api/efficiency/model/EnergyRankReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 信息 —————————————————————————————— //

  async getInfo(param, TIP = '查询信息') {
    const DTO = CORE.grpcDTO(InfoClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'energyRank', DTO)
    return resp.content || []
  },
  transInfo(list) {
    const dataList = list.map(({ name, useCount }, i) => [
      `TOP ${i < 9 ? '0' : ''}${i + 1}`,
      name,
      CORE.numStr(useCount.toFixed(2)),
    ])
    return { dataList }
  },
}
